package com.example.transferfile;

import java.io.File;
import java.util.List;

import org.apache.commons.net.ftp.FTPFile;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class adapterfftp extends BaseAdapter{

	Context context;
	List<FTPFile> name;
	
	@Override
	public int getCount() {
		if(name == null)
		{
			return 0;
		}
		return name.size();
	}
	public adapterfftp(Context context, List<FTPFile> ten) {
		
		this.context=context;
		this.name = ten;
		
	}
	@Override
	public Object getItem(int position) {
		
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inf=(LayoutInflater)
				context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowview=inf.inflate(R.layout.row,parent, false);
		
		TextView textview=(TextView)rowview.findViewById(R.id.rowtext);
		ImageView imageview=(ImageView)rowview.findViewById(R.id.imageView1);
		
		textview.setText(name.get(position).getName());
		if(name.get(position).isDirectory()){
			imageview.setImageResource(R.drawable.ic_folder);
		}else{

			imageview.setImageResource(R.drawable.ic_file);
		}
		return rowview;

	}

}
